package com.fisher.checker;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;

public class DateUtils {

    public static String getCurrentTime()
    {
        Calendar localCalendar = Calendar.getInstance();

        TimeZone chinaTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
        localCalendar.setTimeZone(chinaTimeZone);

        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA);
        dateFormat.setTimeZone(chinaTimeZone);

        return dateFormat.format(localCalendar.getTime());
    }

    public static String getTimeHMSM(){
        Calendar localCalendar = Calendar.getInstance();
        TimeZone chinaTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
        localCalendar.setTimeZone(chinaTimeZone);

        DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss.SSS", Locale.CHINA);
        dateFormat.setTimeZone(chinaTimeZone);

        return dateFormat.format(localCalendar.getTime());
    }

    public static String getCurrentDay(){
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.CHINA);
        return dateFormat.format(new Date());
    }

}
